﻿/***************** 
* 文件描述： 
* 创建人:王俊惠; 
* 创建日期：2017/02/11; 
* 其他：
**********************/
using UnityEngine;
using System.Collections;

namespace MyIdolUIFrameWork
{
    public abstract class Global
    {
        public static GameObject FindChild(Transform trans, string childName)
        {
            Transform child = trans.Find(childName);
            if (child != null)
            {
                return child.gameObject;
            }
            int count = trans.childCount;
            GameObject go = null;
            for (int i = 0; i < count; ++i)
            {
                child = trans.GetChild(i);
                go = FindChild(child, childName);
                if (go != null)
                    return go;
            }
            return null;
        }

        public static T FindChild<T>(Transform trans, string childName) where T : Component
        {
            GameObject go = FindChild(trans, childName);
            if (go == null)
                return null;
            return go.GetComponent<T>();
        }

        public static string GetMinuteTime(float time)
        {
            int mm, ss;
            string stime = "0:00";
            if (time <= 0) return stime;
            mm = (int)time / 60;
            ss = (int)time % 60;
            if (mm > 60)
                stime = "59:59";
            else if (mm < 10 && ss >= 10)
            {
                stime = "0" + mm + ":" + ss;
            }
            else if (mm < 10 && ss < 10)
            {
                stime = "0" + mm + ":0" + ss;
            }
            else if (mm >= 10 && ss < 10)
            {
                stime = mm + ":0" + ss;
            }
            else
            {
                stime = mm + ":" + ss;
            }
            return stime;
        }

    }
}
